package testiranjeSoftvera.actions;

import java.awt.event.ActionEvent;
import java.util.ArrayList;

import testiranjeSoftvera.GuiElements.VirusEditorDialog;
import testiranjeSoftvera.phage.PhageCore;

public class ComboBoxAction extends AbstractTestAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3256311545542727487L;

	public ComboBoxAction() {

	}

	@Override
	public void actionPerformed(ActionEvent e) {

		String tmp = VirusEditorDialog.getInstance().getVirusType()
				.getSelectedItem().toString();

		switch (tmp) {
		case "Speedy":

			System.out.println("Izabran je speedy virus");
			ArrayList<Integer> stats = PhageCore.getInstance().getSpeedyVirus()
					.getVirusStats();
			for (int i = 0; i < stats.size(); i++) {

				VirusEditorDialog.getInstance().getTxtFields().get(i)
						.setText(stats.get(i).toString());
				
				VirusEditorDialog.getInstance().getTxtFields().get(i).setEnabled(true);

			}

			break;
		case "Slow":
			System.out.println("Izabran je slow virus");
			stats = PhageCore.getInstance().getSlowVirus().getVirusStats();
			for (int i = 0; i < stats.size(); i++) {

				VirusEditorDialog.getInstance().getTxtFields().get(i)
						.setText(stats.get(i).toString());
				VirusEditorDialog.getInstance().getTxtFields().get(i).setEnabled(true);

			}
			break;
		case "Warrior":
			stats = PhageCore.getInstance().getWarriorWirus().getVirusStats();
			for (int i = 0; i < stats.size(); i++) {

				VirusEditorDialog.getInstance().getTxtFields().get(i)
						.setText(stats.get(i).toString());
				VirusEditorDialog.getInstance().getTxtFields().get(i).setEnabled(true);

			}
			System.out.println("Izabran je warrior virus");
			break;

		default:
			for (int i = 0; i < VirusEditorDialog.getInstance().getTxtFields()
					.size(); i++) {
				VirusEditorDialog.getInstance().getTxtFields().get(i)
						.setText("");
				VirusEditorDialog.getInstance().getTxtFields().get(i).setEnabled(false);
			}
		}

	}

}
